# -*- coding: utf-8 -*-
'''
Created on 2011-8-14

@author: zxz
'''
import json

SUCC_CODE = '200'
SERVER_ERROR_CODE = '600'
NO_AUTH_ERROR_CODE = '500'

def success(data = {}):
    r = {}
    r['code'] = SUCC_CODE
    r['data'] = data
    r['hasError'] = False
    return json.dumps(r)

def error(code, msg):
    r = {}
    r['code'] = code
    r['error'] = msg
    r['hasError'] = True
    return json.dumps(r)

def json_str(data):
    ''' 由对象转为json '''
    return json.dumps(data)

def load_json(s):
    ''' 由json转为对象 '''
    return json.loads(s)
